package com.yonyou.pmclouds.task.processor;

import com.yonyou.pmclouds.basecom.bp.processor.MultiProcessor;
import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.im.util.IMExecutor;
import com.yonyou.pmclouds.task.entity.TaskVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TaskIMPushProcessor implements SingleProcessor<TaskVO>,MultiProcessor<TaskVO> {

    @Autowired
    private IMExecutor imExecutor;

    @Override
    public void process(TaskVO[] taskVOs, TaskVO[] origTaskVOs) throws BusinessException {
        // 目前批量生成代办，都是同一类单据，因此判断第一个即可
        if (StringUtils.isNotEmpty(taskVOs[0].getPk_receiver()))
            imExecutor.pushTodoMessage(taskVOs);
    }

    @Override
    public void process(TaskVO vo, TaskVO orig) throws BusinessException {
        process(new TaskVO[]{vo},null);
    }
}
